home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / findPanelInConfiguration.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.4 KB  |  76 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date: 
  22. //  Author:         
  23. //
  24.  
  25. global proc int findPanelInConfiguration(
  26.     string $panelConfiguration, 
  27.     string $panelType)
  28. //
  29. //    Description:
  30. //        Look for a specific panel type in a panel configuration.  If the
  31. //        panel configuration contains the panel then the index (0 based)
  32. //        of the panel is returned.
  33. //
  34. //    Arguments:
  35. //        panelConfiguration - A panel configuration.
  36. //
  37. //        panelType          - A panel type.
  38. //
  39. //    Returns:
  40. //        The 0-based index of the panel if it is found in the panel
  41. //        configuration.  -1 is returned if the panel is not found.
  42. //
  43. {
  44.     int $result = -1;
  45.     
  46.     string $createStrings[] = `panelConfiguration -query -createStrings $panelConfiguration`;
  47.     string $panelTypes[] = `panelConfiguration -query -typeStrings $panelConfiguration`;
  48.     string $buffer[];
  49.  
  50.     for ($panelIndex = 0; $panelIndex < size ($panelTypes); $panelIndex++) {
  51.         if ("scriptedPanel" == $panelTypes[$panelIndex]) {
  52.  
  53.             //    Tokenize the panel creation string, looking for the -type flag
  54.             //    to determine the scripted panel type.
  55.             //
  56.             $type = "";
  57.             $tokenCount = tokenize($createStrings[$panelIndex], $buffer);
  58.             for ($index = 0; $index < size ($buffer); $index++) {
  59.                 if ("-type" == $buffer[$index] || "-typ" == $buffer[$index]) {
  60.                     $type = $buffer[$index + 1];
  61.                     break;
  62.                 }
  63.             }
  64.  
  65.             if ("" != $type) {
  66.                 if ($panelType == $type || ("\"" + $panelType + "\"") == $type) {
  67.                     $result = $panelIndex;
  68.                     break;
  69.                 }
  70.             }
  71.         }
  72.     }
  73.  
  74.     return $result;
  75. }
  76.